package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import POJO.AreaCurso;
import POJO.Instituicao;


public class InstituicaoDAO 
{
	Connection c;
	
	public InstituicaoDAO() 
	{		
		GenericDao gDao = new GenericDao();
		c = gDao.getConnection();
	}
	
	public List<Instituicao> listaInstituicao() throws SQLException
	{
		List<Instituicao> listaInstituicao = new ArrayList<Instituicao>();
		String sql = "SELECT * FROM Instituicao ORDER BY nomeInstituicao";
		PreparedStatement ps = c.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		while(rs.next())
		{
			Instituicao inst = new Instituicao();
			inst.setCodInstituicao(rs.getInt("codInstituicao"));
			inst.setNomeInst(rs.getString("nomeInstituicao"));
			listaInstituicao.add(inst);
		}
		rs.close();
		ps.close();
		return listaInstituicao;
	}
	

}
